/*
 * Copyright 2010 Pierre-Yves Ricau
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.excilys.ptitwrap;

/**
 * A {@link LocalWrapRecipeCreator} is able to compute {@link WrapRecipe}s,
 * given the expected number of wraps.
 * 
 * @author Pierre-Yves Ricau
 * 
 */
public class LocalWrapRecipeCreator {

	/**
	 * Computes a {@link WrapRecipe} according to the number of wraps
	 * 
	 * @param numberOfWraps
	 *            expected number of wraps, must be &gt;= 0
	 * @return the recipe
	 * @throws IllegalArgumentException
	 *             if the number of wraps is &lt; 0.
	 */
	public WrapRecipe computeRecipe(int numberOfWraps) {

		if (numberOfWraps < 0) {
			throw new IllegalArgumentException("Number of wraps should not be less than zero");
		}

		WrapRecipe recipe = new WrapRecipe();

		recipe.setNumberOfWraps(numberOfWraps);
		recipe.setSaladWeight(17 * numberOfWraps);
		recipe.setSaladPackNb((int) Math.ceil(numberOfWraps / 18.));
		recipe.setBearnaiseWeight((int) Math.ceil(numberOfWraps * 13.4));
		recipe.setBearnaisePackNb((int) Math.ceil(numberOfWraps / 18.));
		recipe.setCheeseNb(numberOfWraps);
		recipe.setCheesePackNb((int) Math.ceil(numberOfWraps / 9.));
		recipe.setTomatoNb(numberOfWraps);
		recipe.setTortillaNb(numberOfWraps);
		recipe.setTortillaPackNb((int) Math.ceil(numberOfWraps / 6.));

		recipe.setChickenNuggetNb(numberOfWraps * 2);
		recipe.setChickenNuggetPackNb((int) Math.ceil(numberOfWraps / 6.));

		return recipe;
	}

}
